import QtQuick 1.0
import "../Util/Util.js" as Util

ListView {
    id: _root
    x: 0
    y: 0
    width: parent.width
    height: parent.height
    clip: true      //これをしないと下へスクロールする時に周りに食い込む

    property bool loading: (count < 1)

    property bool more_new: contentY < 0  //上へ突き抜けた
    property bool more: (contentY + height) > contentHeight   //下へ突き抜けた


    property bool alwaysViewing: false                     //常に表示するか

    property alias scrollBarVisible: _scrollVar.visible     //表示するか
    property alias scrollBarColor: _scrollVar.color         //色
    property real scrollBarOpacity: 0.8     //透過率

    Rectangle {
        id: _scrollVar
        anchors.right: parent.right
        anchors.rightMargin: 2
        y: parent.height * visibleArea.yPosition
        width: 4
        radius: 2
        height: parent.height * visibleArea.heightRatio
        color: "#ffffff"
        opacity: alwaysViewing ? scrollBarOpacity : 0.0
        visible: (visibleArea.heightRatio < 1.0) | alwaysViewing
    }

    //読込中
    Image {
        anchors.centerIn: parent
        source: "../images/spinner.png"

        NumberAnimation on rotation {
            from: 0
            to: 360
            duration: 1500
            loops: Animation.Infinite
            running: loading
        }
        visible: loading
    }


    states: [
        State {
            name: "Visible"
            when: movingVertically | alwaysViewing
            PropertyChanges {
                target: _scrollVar
                opacity: scrollBarOpacity
            }
        }
    ]

    //アニメーション
    transitions:
        Transition {
            PropertyAnimation {
                easing.type: Easing.OutCubic
                target: _scrollVar
                properties: "opacity"
                duration: 300
            }
        }

}
